home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / PaintEvent.java < prev    next >
Text File  |  1998-09-22  |  3KB  |  106 lines

  1. /*
  2.  * @(#)PaintEvent.java    1.7 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt.event;
  16.  
  17. import java.awt.Component;
  18. import java.awt.Event;
  19. import java.awt.Rectangle;
  20.  
  21. /**
  22.  * The component-level paint event.
  23.  * This event is a special type which is used to ensure that
  24.  * paint/update method calls are serialized along with the other
  25.  * events delivered from the event queue.  This event is not
  26.  * designed to be used with the Event Listener model; programs
  27.  * should continue to override paint/update methods in order
  28.  * render themselves properly.
  29.  *
  30.  * @version 1.7 07/01/98
  31.  * @author Amy Fowler
  32.  */
  33. public class PaintEvent extends ComponentEvent {
  34.  
  35.     /**
  36.      * Marks the first integer id for the range of paint event ids.
  37.      */    
  38.     public static final int PAINT_FIRST        = 800;
  39.  
  40.     /**
  41.      * Marks the last integer id for the range of paint event ids.
  42.      */
  43.     public static final int PAINT_LAST        = 801;
  44.  
  45.     /**
  46.      * The paint event type.  
  47.      */
  48.     public static final int PAINT = PAINT_FIRST;
  49.  
  50.     /**
  51.      * The update event type.  
  52.      */
  53.     public static final int UPDATE = PAINT_FIRST + 1; //801
  54.  
  55.     Rectangle updateRect;
  56.  
  57.     /*
  58.      * JDK 1.1 serialVersionUID 
  59.      */
  60.     private static final long serialVersionUID = 1267492026433337593L;
  61.  
  62.     /**
  63.      * Constructs a PaintEvent object with the specified source component
  64.      * and type.
  65.      * @param source the object where the event originated
  66.      * @id the event type
  67.      * @updateRect the rectangle area which needs to be repainted
  68.      */
  69.     public PaintEvent(Component source, int id, Rectangle updateRect) {
  70.         super(source, id);
  71.         this.updateRect = updateRect;
  72.     }
  73.  
  74.     /**
  75.      * Returns the rectangle representing the area which needs to be
  76.      * repainted in response to this event.
  77.      */
  78.     public Rectangle getUpdateRect() {
  79.         return updateRect;
  80.     }
  81.  
  82.     /**
  83.      * Sets the rectangle representing the area which needs to be
  84.      * repainted in response to this event.
  85.      * @param updateRect the rectangle area which needs to be repainted
  86.      */
  87.     public void setUpdateRect(Rectangle updateRect) {
  88.         this.updateRect = updateRect;
  89.     }
  90.  
  91.     public String paramString() {
  92.         String typeStr;
  93.         switch(id) {
  94.           case PAINT:
  95.               typeStr = "PAINT";
  96.               break;
  97.           case UPDATE:
  98.               typeStr = "UPDATE";
  99.               break;
  100.           default:
  101.               typeStr = "unknown type";
  102.         }
  103.         return typeStr + ",updateRect="+(updateRect != null ? updateRect.toString() : "null");
  104.     }
  105. }
  106.